<template>
    <div class="box">
        <tab title="详情"></tab>
        <van-tabs v-model:active="active" animated>
            <van-tab title="首页">
                <swipe :title="list.pics"></swipe>
                <div>{{ list.goods_name }}</div>
                <div style="color: red;">¥{{ list.goods_price }}</div>
            </van-tab>

            <van-tab title="详情">
                <div v-html="list.goods_introduce"></div>
            </van-tab>
            <van-tab title="评价">内容 3</van-tab>
        </van-tabs>

        <van-action-bar>
            <van-action-bar-icon icon="chat-o" text="客服" />
            <van-action-bar-icon icon="shop-o" text="店铺" />
            <van-action-bar-button color="#be99ff" type="warning" text="加入购物车" @click="toshop()"/>
            <van-action-bar-button color="#7232dd" type="danger" text="立即购买" />
        </van-action-bar>



    </div>
</template>

<script setup>
import tab from '@/components/tab.vue';
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()
import { ref } from 'vue';
import swipe from '@/components/swipe.vue';
import { detailApi } from '@/api/api';

let id = ref(route.query.id)
let list = ref([])
const getlist = () => {
    detailApi(id.value).then((res) => {
        console.log(res);
        list.value = res.data.message
    })
}
getlist()

import { useCounterStore } from '@/stores/counter'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()


import _ from 'lodash'

const toshop = _.debounce(() =>{
    store.getname(list.value)
    router.push('/home/shop')
}, 150)



</script>

<style lang="scss" scoped>
.box {
    width: 100%;
    height: 100%;

}
</style>